﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;

namespace MockSchoolManagement.Mvc.CustomerMiddleWares
{
    public class CustomIdentityErrorDescriber:IdentityErrorDescriber
    {
        public override IdentityError DefaultError()
        {
            return new IdentityError() {Code = nameof(DefaultError), Description = $"发生了未知的故障"};
        }

        public override IdentityError ConcurrencyFailure()
        {
            return new IdentityError() {Code = nameof(ConcurrencyFailure), Description = "乐观并发失败，对象已被修改"};
        }

        public override IdentityError PasswordMismatch()
        {
            return new IdentityError() {Code = nameof(PasswordMismatch), Description = "密码错误"};
        }

        public override IdentityError InvalidToken()
        {
            return new IdentityError(){Code = nameof(InvalidToken),Description = "无效的令牌"};
        }

        public override IdentityError LoginAlreadyAssociated()
        {
            return new IdentityError(){Code = nameof(LoginAlreadyAssociated),Description = "具有此登录的用户已经存在"};
        }

        public override IdentityError InvalidUserName(string userName)
        {
            return new IdentityError(){Code = nameof(InvalidUserName),Description = $"用户名'{userName}'无效，只能包含字母或数字"};
        }

        public override IdentityError InvalidEmail(string email)
        {
            return new IdentityError(){Code = nameof(InvalidEmail),Description = $"邮箱'{email}'无效。"};
        }

        public override IdentityError PasswordTooShort(int length)
        {
            return new IdentityError(){Code = nameof(PasswordTooShort),Description = $"密码必须至少是{length}字符。"};
        }
    }
}
